#ifdef TARG_SW5
#cc = sw5cc.old -host -O3 
#cc_slave = sw5cc.old  -O3
cc = sw5cc -host -O3 
cc_slave = sw5cc -slave -O3
#endif

#ifdef TARG_SW3
#cc = swcc -O3 #-OPT: unroll_times_max=1 #-msimd 
#cc_slave = sw3cc -O3 #-OPT: unroll_times_max=1# -msimd
#endif

SCHEDULER_INSTALL_PATH=${DAG_HOME}/dag_task_scheduler


EXTRA_FLAGS= -DTMAX=100 -DNX=2000 -DNY=2000 -DTZ1=50 -DTZ2=50 -DCHECK -DPROFILING #-DMMEM
#EXTRA_FLAGS= -DTMAX=100 -DNX=100 -DNY=100 -DTZ1=50 -DTZ2=50 -DCHECK -DPROFILING #-DMMEM

CFLAGS = $(EXTRA_FLAGS)  -I${SCHEDULER_INSTALL_PATH}/include -L${SCHEDULER_INSTALL_PATH}/lib

LIBFLAGS =  -ldag_task_scheduler -lstdc++ -lm 


OBJECT_STATIC = fdtd_master.o fdtd_unre.o
OBJECT_REUSE = fdtd_master.o fdtd_reuse.o
#OBJECT_REUSE_LOOP = fdtd_master.o fdtd_reuse_loop.o
OBJECT_REUSE_V1 = fdtd_master_auto.o fdtd_reuse_v1.o
OBJECT_REUSE_V2 = fdtd_master_auto.o fdtd_reuse_v2.o

all:  reuse_v1 reuse_v2 unreuse reuse 

unreuse: fdtd_master.o fdtd_unre.o fdtd_unreuse
reuse: fdtd_master.o fdtd_reuse.o fdtd_reuse
#reusel: fdtd_master.o fdtd_reuse_loop.o fdtd_reuse_loop
reuse_v1: fdtd_master_auto.o fdtd_reuse_v1.o fdtd_reuse_v1
reuse_v2: fdtd_master_auto.o fdtd_reuse_v2.o fdtd_reuse_v2

fdtd_master.o: fdtd_master.c
	$(cc) $(CFLAGS) -c  fdtd_master.c  $(LIBFLAGS)
fdtd_master_auto.o: fdtd_master_auto.c
	$(cc) $(CFLAGS) -c  fdtd_master_auto.c  $(LIBFLAGS)
fdtd_unre.o: fdtd_unre.c
	$(cc_slave) $(CFLAGS)  -c fdtd_unre.c  $(LIBFLAGS)
fdtd_reuse.o: fdtd_reuse.c
	$(cc_slave) $(CFLAGS) -c fdtd_reuse.c $(LIBFLAGS)
fdtd_reuse_v1.o: fdtd_reuse_v1.c
	$(cc_slave) $(CFLAGS)  -c fdtd_reuse_v1.c  $(LIBFLAGS)
fdtd_reuse_v2.o: fdtd_reuse_v2.c
	$(cc_slave) $(CFLAGS)  -c fdtd_reuse_v2.c  $(LIBFLAGS) 
fdtd_unreuse:
	$(cc_slave) -hybrid   $(CFLAGS)  -o fdtd_unreuse $(OBJECT_STATIC) $(LIBFLAGS)
fdtd_reuse:
	$(cc_slave) -hybrid   $(CFLAGS)  -o fdtd_reuse $(OBJECT_REUSE) $(LIBFLAGS)
fdtd_reuse_v1: 
	$(cc_slave) -hybrid   $(CFLAGS)  -o fdtd_reuse_v1 $(OBJECT_REUSE_V1) $(LIBFLAGS)
fdtd_reuse_v2: 
	$(cc_slave) -hybrid   $(CFLAGS)  -o fdtd_reuse_v2 $(OBJECT_REUSE_V2) $(LIBFLAGS)
clean:
	@-rm -f *.o fdtd_unreuse fdtd_reuse_v1 fdtd_reuse_v2 fdtd_reuse 
